<?php
/**
 * Created by PhpStorm.
 * User: yuanluke
 * Date: 5/4/16
 * Time: 15:05
 */

namespace App\Http\Utils\Common;


class FileUtils {

    public static function getExtName($file){
        return substr(strrchr($file, '.'), 1);
    }



    public static function copyDir($src, $dest) {
        $dir = opendir($src);
        if (!file_exists($dest)) {
            mkdir($dest, 0777, true);
        }
        while(false !== ( $file = readdir($dir)) ) {
            if (( $file != '.' ) && ( $file != '..' )) {
                if ( is_dir($src . '/' . $file) ) {
                    self::copyDir($src . '/' . $file,$dest . '/' . $file);
                    continue;
                }
                else {
                    copy($src . '/' . $file,$dest . '/' . $file);
                }
            }
        }
        closedir($dir);
    }


}